home *** CD-ROM | disk | FTP | other *** search
- /* AOMCreateButtons.c */
- /*
- * AddressOMatic Sample
- * AOMCreatePanels.c
- * Copyright © 1993 Apple Computer Inc. All rights reserved.
- */
- #include "AddressOMaticPrivate.h"
-
- const AOMRadioButton _AOMRadioInfo[kAOMRadioButtons] = {
- { kAOMEnablePDBit, kAOMPDRadioButton, kAOMPDRadioSelect },
- { kAOMEnablePanelBit, kAOMPanelRadioButton, kAOMPanelRadioSelect },
- { kAOMEnableFindBit, kAOMFindRadioButton, kAOMFindRadioSelect }
- #ifdef ENABLE_TYPEIN
- ,
- { kAOMEnableTypeInBit, kAOMTypeInRadioButton, kAOMTypeInRadioSelect }
- #endif
- };
-
- /*
- * This is used to construct a color spec. It could be moved to a 'cctb'
- * resource but that would require avoiding application resources.
- */
- static const CtlCTab gCCTable = {
- 0, 0, 3,
- cFrameColor, kAOMBlackColor,
- cBodyColor, kAOMBackgroundColor,
- cTextColor, kAOMBlackColor,
- cFrameColor, kAOMBlackColor
- };
-
- OSErr _AOMMakeButton(
- register AddressOMaticPtr aomPtr,
- AOMItemIndex titleString,
- ControlHandle *theControlPtr
- );
- void _AOMSetControlColor(
- ControlHandle theControl
- );
-
- OSErr
- _AOMCreateButtons(
- register AddressOMaticPtr aomPtr,
- AOMModeMask enableModeMask
- )
- {
- OSErr status;
- short i;
-
- /*
- * Build the AddressOMatic panel action buttons.
- */
- _AOMSetFont(aomPtr, kAOMLabelFontStyle);
- status = noErr;
- if ((enableModeMask & kAOMShowDoneButtonMask) != 0) {
- status = _AOMMakeButton(
- aomPtr,
- kAOMDoneButtonString,
- &AOM.doneButton
- );
- }
- if (status == noErr
- && (enableModeMask & kAOMShowCCButtonMask) != 0) {
- status = _AOMMakeButton(
- aomPtr,
- kAOMCCButtonString,
- &AOM.ccButton
- );
- }
- if (status == noErr
- && (enableModeMask & kAOMShowToButtonMask) != 0) {
- status = _AOMMakeButton(
- aomPtr,
- kAOMToButtonString,
- &AOM.toButton
- );
- }
- /*
- * Enable the enabled radio buttons.
- */
- for (i = 0; i < kAOMRadioButtons; i++) {
- if ((enableModeMask & (1L << (i + kAOMEnablePDBit))) != 0)
- AOM.radioEnable[i] = TRUE;
- }
- return (status);
- }
-
- OSErr
- _AOMMakeButton(
- register AddressOMaticPtr aomPtr,
- AOMItemIndex titleString,
- ControlHandle *theControlPtr
- )
- {
- OSErr status;
- Rect dummyRect;
- Str255 title;
-
- SetRect(&dummyRect, 0, 0, 0, 0);
- GetIndString(title, AOM.stringsResID, titleString);
- *theControlPtr = NewControl(
- AOM.window, /* Control is in this window */
- &dummyRect, /* Will be reset by decorator */
- title, /* Control label text */
- FALSE, /* Invisible (decorator fixes) */
- 0, 0, 1, /* Values */
- (pushButProc | useWFont), /* Normal button, our font */
- 0 /* No refCon (yet) */
- );
- if (*theControlPtr == NULL)
- status = MemError();
- else {
- status = noErr;
- if (IS_COLOR(AOM.window))
- _AOMSetControlColor(*theControlPtr);
- }
- LOG(status, "\p_AOMMakeButton");
- return (status);
- }
-
- /*
- * This creates a control table color record the first time it's called,
- * but does nothing for subsequent calls (as the table's been created).
- * Only memory errors are possible.
- */
- void
- _AOMSetControlColor(
- ControlHandle theControl
- )
- {
- OSErr status;
- CCTabHandle colorHandle;
-
- /*
- * The default CtlCTab has space for four ColorSpec's, but
- * we only use three. However, something in the system
- * looks at the fourth Grrr.
- */
- status = PtrToHand(
- (Ptr) &gCCTable,
- (Handle *) &colorHandle,
- sizeof (CtlCTab)
- );
- if (status == noErr)
- SetCtlColor(theControl, colorHandle);
- LOG(status, "\p_AOMSetControlColor (ignored)");
- }
-
-
-